/**
 * 
 */
package anyware.common.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @author keke
 * 
 */
public class DeleteWhenCloseFileInputStream extends FileInputStream {
    private final File file;

    public DeleteWhenCloseFileInputStream(final File file)
            throws FileNotFoundException {
        super(file);
        this.file = file;
    }

    public DeleteWhenCloseFileInputStream(final String name)
            throws FileNotFoundException {
        super(name);
        file = new File(name);
    }

    @Override
    public void close() throws IOException {
        super.close();
        file.delete();
    }
}
